home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.02 Feb 90 / cdev Shell Code / cdevShell.p < prev    next >
Encoding:
Text File  |  1989-08-07  |  14.5 KB  |  675 lines  |  [TEXT/MPS ]

  1. PROGRAM cdevShell;
  2.  
  3. USES    MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf,
  4.         cdev;
  5.  
  6. CONST
  7.     cursorDev = 14;
  8.     HwCfgFlgs = $0B22;
  9.     ROM85 = $028E;
  10.  
  11. TYPE
  12.     IntPtr = ^integer;
  13.     IntHandle = ^IntPtr;
  14.     RectPtr = ^rect;
  15.     EventPtr = ^EventRecord;
  16.  
  17. PROCEDURE doMenu(l: longInt);    FORWARD;
  18. PROCEDURE updateDial;    FORWARD;
  19. PROCEDURE drawIcon(ih: Handle; selected: Boolean; r: Rect);    FORWARD;
  20. PROCEDURE startupCdev;    FORWARD;
  21. PROCEDURE shutDownCdev;    FORWARD;
  22. PROCEDURE cdevInitDev;    FORWARD;
  23. PROCEDURE cdevHitDev(item: integer; e: EventPtr);    FORWARD;
  24. PROCEDURE cdevUpdateDev;    FORWARD;
  25. PROCEDURE cdevNulDev(e: EventPtr);    FORWARD;
  26. PROCEDURE cdevCloseDev;    FORWARD;
  27. PROCEDURE cdevEdit(c: integer);    FORWARD;
  28. PROCEDURE cdevKeyEvtDev(e: EventPtr);    FORWARD;
  29. PROCEDURE cdevActivate(e: EventPtr);    FORWARD;
  30. PROCEDURE cdevMacDev;    FORWARD;
  31. PROCEDURE cdevCursorDev;    FORWARD;
  32. PROCEDURE fatalError(s : Str255);    FORWARD;
  33. PROCEDURE warningError(s : Str255);    FORWARD;
  34. PROCEDURE doMsgDialog;    FORWARD;
  35. FUNCTION callCdev( msgCode : integer; item : integer; e : EventPtr;
  36.                    st : longInt) :    longInt;    FORWARD;
  37. PROCEDURE doNRCTs;    FORWARD;
  38. PROCEDURE getNRCTrgn;    FORWARD;
  39. PROCEDURE HiliteDefault(d: DialogPtr); FORWARD;
  40.  
  41. VAR
  42.     cdevDial:        DialogPtr;
  43.     dP:                DialogPeek;
  44.     cdevItems:        integer;
  45.     userItems:        integer;
  46.     teWas:            integer;
  47.     cdevStorage:    longInt;
  48.  
  49.     nrctRgn:        RgnHandle;
  50.     greyRgn:        RgnHandle;
  51.     userArea:        Rect;
  52.  
  53.     stopRect,
  54.     startRect:        Rect;
  55.     myStopIcon,
  56.     myStartIcon:    Handle;
  57.  
  58.     cursorIsArrow:    Boolean;
  59.     cdevMsgOff:        array[0 .. 16] of Boolean;
  60.     selected:        Boolean;
  61.     running:        Boolean;
  62.  
  63.     env:            SysEnvRec;
  64.     entryVref:        integer;
  65.     otherWindow:    WindowPtr;
  66.     error:            integer;
  67.  
  68. { ******* }
  69.     i,j:            integer;
  70.     temp, cdevDITL:    Handle;
  71.     e:                EventRecord;
  72.     rH:                RgnHandle;
  73.     whichWindow:    WindowPtr;
  74.     key:            char;
  75.     p:                Point;
  76.     s:                Str255;
  77.     hasCursor:        Boolean;
  78.     teH:            TEHandle;
  79.     trashB:            Boolean;
  80.  
  81. PROCEDURE doMenu(l: longInt);
  82. VAR    menu, choice, i:    integer;
  83.     daName:                Str255;
  84.     d:                    DialogPtr;
  85. BEGIN
  86.     menu := HiWord(l);
  87.     choice := LoWord(l);
  88.     
  89.     case menu of
  90.         1:    BEGIN
  91.                 if choice = 1 then BEGIN
  92.                     d := GetNewDialog(132, nil, WindowPtr(-1));
  93.                     HiliteDefault(d);
  94.                     repeat
  95.                         ModalDialog(nil, i)
  96.                     until i = 1;
  97.                     DisposDialog(d);
  98.                 END;
  99.                 if choice > 1 then BEGIN
  100.                     GetItem(GetMHandle(1), choice, daName);
  101.                     error := OpenDeskAcc(daName);
  102.                 END;
  103.             END;
  104.         2:    case choice of
  105.                 1: startupCdev;
  106.                 2: shutDownCdev;
  107.                 4: running := false;
  108.             END;
  109.         3:    if FrontWindow = cdevDial then
  110.                 cdevEdit(choice)
  111.             else
  112.                 trashB := SystemEdit(choice - 1);
  113.         4:    case choice of
  114.                 1: doMsgDialog;
  115.                 2: InvalRect(GrafPtr(cdevDial)^.portRect);
  116.             END; { of case }
  117.     END; { of case }
  118.     HiliteMenu(0);
  119. END;
  120.  
  121. PROCEDURE updateDial;
  122. VAR
  123.     r:            Rect;
  124.     patHand:    PatHandle;
  125.     i:            integer;
  126.     h:            Handle;
  127. BEGIN
  128.     SetPort(cdevDial);
  129.     TextSize(9);
  130.     
  131.     PenSize(2,2);
  132.     
  133.     patHand := GetPattern(-16000);
  134.     PenPat(patHand^^);
  135.     PaintRgn(nrctRgn);
  136.     PenPat(black);
  137.  
  138.     doNRCTs;
  139.     r := cdevDial^.portRect;
  140.     InsetRect(r, -2, -2);
  141.     r.top := r.top + 1;
  142.     FrameRect(r);
  143.  
  144.     GetDItem(cdevDial, 2, i, h, r);
  145.     r.top := r.top - 2;
  146.     r.bottom := r.bottom -1;
  147.     r.left := r.left - 2;
  148.     r.right := r.right + 1;
  149.     FrameRect(r);
  150.  
  151.     GetDItem(cdevDial, 1, i, h, r);
  152.     r.top := r.top - 2;
  153.     r.bottom := r.bottom + 2;
  154.     r.left := r.left - 2;
  155.     r.right := r.right + 2;
  156.     FrameRect(r);
  157.  
  158.     PenSize(1,1);
  159.  
  160.     drawIcon(myStopIcon, not selected, stopRect);
  161.     drawIcon(myStartIcon, selected, startRect);
  162. END;
  163.  
  164. PROCEDURE drawIcon(ih: Handle; selected: Boolean; r: Rect);
  165. VAR
  166.     iconBitMap:    BitMap;
  167.     fromR:        Rect;
  168. BEGIN
  169.     SetRect(fromR, 0, 0, 32, 32);
  170.     iconBitMap.rowBytes := 4;
  171.     iconBitMap.bounds := fromR;
  172.     HLock(iH);
  173.     if (selected) then BEGIN
  174.         iconBitMap.baseAddr := Ptr(ORD4(iH^) + longInt(128));
  175.         CopyBits(iconBitMap, GrafPtr(cdevDial)^.portBits, fromR, r, srcCopy, nil);
  176.  
  177.         iconBitMap.baseAddr := ih^;
  178.         CopyBits(iconBitMap, GrafPtr(cdevDial)^.portBits, fromR, r, srcXor, nil);
  179.     END
  180.     else BEGIN
  181.         iconBitMap.baseAddr := ih^;
  182.         CopyBits(iconBitMap, GrafPtr(cdevDial)^.portBits, fromR, r, srcCopy, nil);
  183.     END;
  184.     HUnlock(iH);
  185. END;
  186.  
  187. PROCEDURE startupCdev;
  188. VAR
  189.     temp:                Handle;
  190.     i,j,totalItems:        integer;
  191.     hardMask, softMask:    integer;
  192.     p:                    Ptr;
  193.     c:                    ControlHandle;
  194.     tempD:                DialogPtr;
  195.     r:                    Rect;
  196. BEGIN
  197.     selected := true;
  198.     
  199.     getNRCTrgn;
  200.     
  201.     temp := GetResource('mach', -4064);
  202.     if temp = nil then
  203.         fatalError('mach -4064 resource not found');
  204.     softMask := IntHandle(temp)^^;
  205.     hardMask := IntPtr(2+ORD4(temp^))^;
  206.     if (softMask = 0) and (hardMask = $ffff) then BEGIN
  207.         cdevMacDev;
  208.         if cdevStorage = 0 then
  209.             fatalError('cdev refuses to run on this machine');
  210.         if cdevStorage <> 1 then
  211.             fatalError('Invalid result returned from macDev call');
  212.     END
  213.     else BEGIN
  214.         if integer(BitAnd(softMask, IntPtr(ROM85)^)) <> Intptr(ROM85)^ then
  215.             fatalError('cdev failed SoftMask test');
  216.         if integer(BitAnd(hardMask, IntPtr(HwCfgFlgs)^)) <> hardMask then
  217.             fatalError('cdev failed HardMask test');
  218.     END;
  219.     ReleaseResource(temp);
  220.  
  221.     IntHandle(dP^.items)^^ := cdevItems + userItems;
  222.     dP^.editField := teWas;
  223.     if teWas <> -1 then
  224.         TEActivate( dP^.textH);
  225.     SetPort(cdevDial);
  226.     TextSize(9);
  227.     for i:= cdevItems + 1 to cdevItems + userItems do
  228.         ShowDItem(cdevDial,i);
  229.  
  230.     doNRCTs;
  231.     
  232.     DisableItem(GetMHandle(2),1);
  233.     EnableItem(GetMHandle(2), 2);
  234.  
  235.     cdevInitDev;
  236.  
  237.     InvalRect(GrafPtr(cdevDial)^.portRect);
  238. END;
  239.  
  240. PROCEDURE shutDownCdev;
  241. VAR    i:    integer;
  242. BEGIN
  243.     cdevCloseDev;
  244.  
  245.     SetCursor(arrow);
  246.     cursorIsArrow := true;
  247.  
  248.     if cdevStorage <> 0 then
  249.         warningError('Close call did not return zero');
  250.  
  251.     for i := cdevItems + 1 to cdevItems + userItems do
  252.         HideDItem(cdevDial, i);
  253.     
  254.     IntHandle(dP^.items)^^ := cdevItems;
  255.     dP^.editField := -1;
  256.     if teWas <> -1 then
  257.         TEDeactivate(dP^.textH);
  258.  
  259.     selected := false;
  260.  
  261.     getNRCTrgn;
  262.  
  263.     EnableItem(GetMHandle(2), 1);
  264.     DisableItem(GetMHandle(2), 2);
  265.  
  266.     InvalRect(GrafPtr(cdevDial)^.portRect);
  267. END;
  268.  
  269. PROCEDURE cdevInitDev;
  270. BEGIN
  271.     cdevStorage := callCdev(initDev, 0, nil, cdevUnset);
  272. END;
  273.  
  274. PROCEDURE cdevHitDev(item: integer; e: EventPtr);
  275. BEGIN
  276.     cdevStorage := callCdev(hitDev, item, e, cdevStorage);
  277. END;
  278.  
  279. PROCEDURE cdevUpdateDev;
  280. BEGIN
  281.     cdevStorage := callCdev(updateDev, 0, nil, cdevStorage);
  282. END;
  283.  
  284. PROCEDURE cdevNulDev(e: EventPtr);
  285. BEGIN
  286.     cdevStorage := callCdev(nulDev, 0, e, cdevStorage);
  287. END;
  288.  
  289. PROCEDURE cdevCloseDev;
  290. BEGIN
  291.     cdevStorage := callCdev(closeDev, 0, nil, cdevStorage);
  292. END;
  293.  
  294. PROCEDURE cdevEdit(c: integer);
  295. BEGIN
  296.     case c of
  297.         1:    i := undoDev;
  298.         3:     i := cutDev;
  299.         4:    i := copyDev;
  300.         5:    i := pasteDev;
  301.         6:    i := clearDev;
  302.     END;
  303.     cdevStorage := callCdev(i, 0, nil, cdevStorage);
  304. END;
  305.  
  306. PROCEDURE cdevKeyEvtDev(e: EventPtr);
  307. BEGIN
  308.     cdevStorage := callCdev(keyEvtDev, 0, e, cdevStorage);
  309. END;
  310.  
  311. PROCEDURE cdevActivate(e: EventPtr);
  312. VAR    i:        integer;
  313. BEGIN
  314.     if BitAnd(e^.modifiers, activeFlag) <> 0 then
  315.         i := activDev
  316.     else
  317.         i := deactivDev;
  318.     cdevStorage := callCdev(i, 0, e, cdevStorage);
  319. END;
  320.  
  321. PROCEDURE cdevMacDev;
  322. BEGIN
  323.     cdevStorage := callCdev(macDev, 0, nil, cdevStorage);
  324. END;
  325.  
  326. PROCEDURE cdevCursorDev;
  327. BEGIN
  328.     cdevStorage := callCdev(cursorDev, 0, nil, cdevStorage);
  329. END;
  330.  
  331. FUNCTION callCdev( msgCode : integer; item : integer; e : EventPtr;
  332.                    st : longInt) :    longInt;
  333.     var    rValue:    longInt;
  334.         error :    integer;
  335. BEGIN
  336.     if (not selected) or (cdevMsgOff[msgCode]) then BEGIN
  337.         callCdev := st;
  338.         exit(callCdev);
  339.     END;
  340.  
  341.     SetPort(cdevDial);
  342.     TextSize(9);
  343.     error := SetVol(nil, env.sysVRefNum);
  344.     rValue := Sample(msgCode, item, cdevItems, 0, e^, st, cdevDial);
  345.     error := SetVol(nil, entryVref);
  346.  
  347.     if (msgCode <> macDev) and (msgCode <> closeDev) then
  348.         case rValue of
  349.             cdevGenErr:    fatalError('General cdev error');
  350.             cdevMemErr: fatalError('cdev insufficient memory error');
  351.             cdevResErr: fatalError('cdev could not locate needed resource');
  352.         END; { of case }
  353.     callCdev := rValue;
  354. END;
  355.  
  356. PROCEDURE fatalError(s : Str255);
  357. BEGIN
  358.     ParamText(s, '', '', '');
  359.     error := Alert(130, nil);
  360.     ExitToShell;
  361. END;
  362.  
  363. PROCEDURE warningError(s : Str255);
  364. BEGIN
  365.     ParamText(s, '', '', '');
  366.     error := Alert(131, nil);
  367. END;
  368.  
  369. PROCEDURE doMsgDialog;
  370. VAR    d:        DialogPtr;
  371.     i,kind:    integer;
  372.     r:        Rect;
  373.     h:        Handle;
  374. BEGIN
  375.     d := GetNewDialog(128, nil, WindowPtr(-1));
  376.     HiliteDefault(d);
  377.  
  378.     for i:= initDev + 3 to cursorDev + 3 do BEGIN
  379.         GetDItem(d, i, kind, h, r);
  380.         kind := integer(cdevMsgOff[i-3]);
  381.         if kind <> 0 then
  382.             kind := 1;
  383.         SetCtlValue(ControlHandle(h), kind);
  384.     END;
  385.     
  386.     repeat
  387.         ModalDialog(nil, i);
  388.         if i > 2 then BEGIN
  389.             GetDItem(d, i, kind, h, r);
  390.             SetCtlValue(ControlHandle(h), ABS(GetCtlValue(ControlHandle(h)) - 1));
  391.         END
  392.     until i <= 2;
  393.  
  394.     if i = 1 then BEGIN
  395.         for i:= initDev + 3 to cursorDev + 3 do BEGIN
  396.             GetDItem(d, i, kind, h, r);
  397.             cdevMsgOff[i-3] := Boolean(GetCtlValue(ControlHandle(h)));
  398.         END;
  399.         h := GetResource('msks', 128);
  400.         if h <> nil then BEGIN
  401.             BlockMove(Ptr(@cdevMsgOff), h^, 16);
  402.             ChangedResource(h);
  403.             WriteResource(h);
  404.         END;
  405.     END;
  406.  
  407.     DisposDialog(d);
  408. END;
  409.  
  410. PROCEDURE doNRCTs;
  411. VAR    h:        Handle;
  412.     r:        RectPtr;
  413.     i:        integer;
  414. BEGIN
  415.     if not selected then
  416.         exit(doNRCTs);
  417.  
  418.     h := GetResource('nrct', -4064);
  419.     r := RectPtr(2 + ORD4(h^));
  420.     for i:= 1 to IntHandle(h)^^ do BEGIN
  421.         EraseRect(r^);
  422.         FrameRect(r^);
  423.         r := RectPtr(ORD4(r) + sizeof(Rect));
  424.     END; { of loop }
  425.     ReleaseResource(h);
  426. END;
  427.  
  428. PROCEDURE getNRCTrgn;
  429. VAR
  430.     h:        Handle;
  431.     r:        RectPtr;
  432.     rct:    Rect;
  433.     i:        integer;
  434.     rRgn:    RgnHandle;
  435. BEGIN
  436.     if not selected then
  437.         BEGIN
  438.             SetRect(rct, 86, -1, 322, 255);
  439.             nrctRgn := NewRgn;
  440.             RectRgn(nrctRgn, rct);
  441.             exit(getNRCTrgn);
  442.         END;
  443.  
  444.     h := GetResource('nrct', -4064);
  445.     if h = nil then
  446.         fatalError('nrct -4064 resource is missing');
  447.     nrctRgn := NewRgn;
  448.     HLock(h);
  449.     r := RectPtr(2+ORD4(h^));
  450.     for i:= 1 to IntHandle(h)^^ do BEGIN
  451.         rRgn := NewRgn;
  452.         RectRgn(rRgn, r^);
  453.         r := RectPtr(ORD4(r) + sizeof(Rect));
  454.         UnionRgn(nrctRgn, rRgn, nrctRgn);
  455.         DisposeRgn(rRgn);
  456.     END; { of loop }
  457.     HUnlock(h);
  458.     ReleaseResource(h);
  459.  
  460.     SetRect(rct, 86, -1, 322, 255);
  461.     rRgn := NewRgn;
  462.     RectRgn(rRgn, rct);
  463.     DiffRgn(rRgn, nrctRgn, nrctRgn);
  464.     DisposeRgn(rRgn);
  465. END;
  466.  
  467. PROCEDURE mvWindow(w: WindowPtr; p: Point);
  468. VAR    trashR:        Rect;
  469. BEGIN
  470.     trashR := screenBits.bounds;
  471.     InsetRect(trashR, 6, 6);
  472.     DragWindow(w, p, trashR);
  473. END;
  474.  
  475. PROCEDURE HiliteDefault(d: DialogPtr);
  476. VAR    i:            integer;
  477.     box:        Rect;
  478.     h:            Handle;
  479. BEGIN
  480.     SetPort(d);
  481.     GetDItem(d, 1, i, h, box);
  482.     PenSize(3,3);
  483.     InsetRect(box, -4, -4);
  484.     FrameRoundRect(box, 16, 16);
  485. END;
  486.  
  487. PROCEDURE Initialize;
  488. BEGIN
  489.     InitGraf(@thePort);
  490.     InitFonts;
  491.     InitWindows;
  492.     TEInit;
  493.     InitDialogs(nil);
  494.     InitCursor;
  495.     cursorIsArrow := true;
  496.     MaxApplZone;
  497.     
  498.     SetMenuBar( GetNewMBar(256) );
  499.     AddResMenu( GetMHandle(1), 'DRVR');
  500.     DrawMenuBar;
  501.     DisableItem(GetMHandle(2),2);
  502.     
  503.     error := SysEnvirons(0, env);
  504.     error := GetVol(@s, entryVref);
  505.  
  506.     getNRCTrgn;
  507.     
  508.     temp := GetResource('msks', 128);
  509.     if temp <> nil then
  510.         BlockMove(temp^, Ptr(@cdevMsgOff), 16);
  511.  
  512.     hasCursor := ( GetResource('CURS', -4064) <> nil );
  513.  
  514.     SetRect(userArea, 87, 0, 322, 255);
  515.     SetRect(stopRect, 25, 15, 25+32, 15+32);
  516.     SetRect(startRect, 25, 85, 25+32, 85+32);
  517.  
  518.     myStartIcon := GetResource('ICN#', -4064);
  519.     if (myStartIcon = nil) then
  520.         fatalError('Unable to find cdev ICN# -4064 resource');
  521.     myStopIcon := GetResource('ICN#', 128);
  522.  
  523.     selected := false;
  524.  
  525.     cdevDITL := GetResource('DITL', -16000);
  526.     HNoPurge(cdevDITL);
  527.     temp := GetResource('DITL', -4064);
  528.     if temp = nil then
  529.         fatalError('Unable to find cdev DITL -4064 resource');
  530.     cdevItems := 1 + IntHandle(cdevDITL)^^;
  531.     
  532.     userItems := IntHandle(temp)^^;
  533.     IntHandle(cdevDITL)^^ := cdevItems + userItems;
  534.     i := GetHandleSize( cdevDITL );
  535.     j := GetHandleSize( temp );
  536.     SetHandleSize(cdevDITL, i+j-2);
  537.     BlockMove(Ptr(2 + ORD4(temp^)), Ptr(i + ORD4(cdevDITL^)), j-2);
  538.     
  539.     SetDAFont(1);
  540.     cdevDial := GetNewDialog(-16000, nil, WindowPtr(-1));
  541.     SetDAFont(0);
  542.     dP := DialogPeek(cdevDial);
  543.     SetPort(cdevDial);
  544.     TextSize(9);
  545.     ShowWindow(cdevDial);
  546.     for i:= cdevItems + 1 to cdevItems+userItems do
  547.         HideDItem(cdevDial, i);
  548.  
  549.     IntHandle(dP^.items)^^ := cdevItems;
  550.     teWas := dP^.editField;
  551.     dP^.editField := -1;
  552.     if teWas >= 0 then BEGIN
  553.         teH := dp^.textH;
  554.         teH^^.txSize := 9;
  555.     END;
  556.  
  557.     otherWindow := GetNewWindow(128, nil, WindowPtr(0));
  558. END; { of Initialize}
  559.  
  560. PROCEDURE DoNullEvent;
  561. BEGIN
  562.     cdevNulDev(@e);
  563.     SetPort(cdevDial);
  564.     GetMouse(p);
  565.     if (FrontWindow = cdevDial) and PtInRect(p, userArea) then BEGIN
  566.         if hasCursor then 
  567.             cdevCursorDev
  568.         else 
  569.             if cursorIsArrow then
  570.                 SetCursor(GetCursor(crossCursor)^^);
  571.         cursorIsArrow := false;
  572.     END
  573.     else
  574.         if not cursorIsArrow then BEGIN
  575.             SetCursor(arrow);
  576.             cursorIsArrow := true
  577.         END
  578. END; { of doNullEvent }
  579.  
  580. PROCEDURE DoMouseDown;
  581. BEGIN
  582.     i := FindWindow(e.where, whichWindow);
  583.     case i of
  584.         inMenuBar:    doMenu( MenuSelect(e.where) );
  585.         inDrag:        BEGIN
  586.                         mvWindow(whichWindow, e.where);
  587.                         e.what := nullEvent;
  588.                     END;
  589.         inGoAway:    if TrackGoAway(whichWindow, e.where) then
  590.                         running := false;
  591.         inSysWindow: SystemClick(e, whichWindow);
  592.         inContent:    BEGIN
  593.                         if FrontWindow <> whichWindow then BEGIN
  594.                             SelectWindow(whichWindow);
  595.                             e.what := nullEvent
  596.                         END
  597.                         else if (FrontWindow = cdevDial) then BEGIN
  598.                             p := e.where;
  599.                             GlobalToLocal(p);
  600.                             if (not selected) and PtInRect(p, startRect) then
  601.                                     startUpCdev;
  602.                             if selected and PtInRect(p, stopRect) then
  603.                                     shutDownCdev;
  604.                         END; { of if frontWindow}
  605.                     END; { of inContent}
  606.         END; { end of case }
  607. END;
  608.  
  609. { the Main procedure }
  610. BEGIN
  611.     Initialize;
  612.  
  613.     running := true;
  614.     while running do BEGIN
  615.         SystemTask;
  616.         
  617.         if dp^.editField >= 0 then
  618.             TEIdle( dp^.textH);
  619.         
  620.         if GetNextEvent(everyEvent, e) then BEGIN
  621.  
  622.             if (e.what = keyDown) or (e.what = autoKey) then BEGIN
  623.                 key := char(BitAnd(e.message,charCodeMask));
  624.                 if BitAnd(e.modifiers, cmdKey) <> 0 then BEGIN
  625.                     doMenu(MenuKey(key));
  626.                     e.what := nullEvent;
  627.                 END;
  628.             END;
  629.             
  630.             if e.what = mouseDown then
  631.                 DoMouseDown;
  632.  
  633.                 if (e.what = updateEvt) and (e.message=longInt(otherWindow))
  634.                     then BEGIN
  635.                     BeginUpdate(otherWindow);
  636.                     EndUpdate(otherWindow);
  637.                 END;
  638.                 if IsDialogEvent(e) then BEGIN
  639.                     if (e.what = updateEvt) and (e.message = longInt(cdevDial))
  640.                         then BEGIN
  641.                         rH := WindowPeek(cdevDial)^.updateRgn;
  642.                         error := HandToHand(Handle(rH));
  643.                         BeginUpdate(cdevDial);
  644.                             updateDial;
  645.                             cdevUpdateDev;
  646.                         EndUpdate(cdevDial);
  647.                         WindowPeek(cdevDial)^.updateRgn := rH;
  648.                     END;
  649.                     if (e.what = keyDown) or (e.what = autoKey) then
  650.                         cdevKeyEvtDev(@e);
  651.                     if e.what = activateEvt then
  652.                         cdevActivate(@e);
  653.                     
  654.                     SetPort(cdevDial);
  655.                     TextSize(9);
  656.                     if DialogSelect(e, cdevDial, i) then BEGIN
  657.                         if e.what = mouseDown then BEGIN
  658.                             if i =1 then
  659.                                 error := Alert(-16000, nil);
  660.                             if i > cdevItems then
  661.                                 cdevHitDev(i, @e);
  662.                         END;
  663.                     END; { of DialogSelect if }
  664.                 END; { of DialogEvent if }
  665.             END; { end of GNE if }
  666.         if e.what = nullEvent then
  667.             doNullEvent;
  668.  
  669.     END;
  670.  
  671.     cdevCloseDev;
  672.     DisposDialog(cdevDial);
  673.     DisposeWindow(otherWindow);
  674. END.
  675.